﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class _chatloginout : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
		Session["vusername"]=null;
		//if(Request["strname"]!="" )
		if (!string.IsNullOrEmpty(Request.QueryString["strname"]))//选中咨询者
			{
				string gname=Request.QueryString["strname"];
                string udate = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                try
				{
					//Response.Write(gname+""+udate);
//					Response.End();
					Socut.Data.ExecuteNonQuery("update web_talkuser set istalk=2,endtime='" + udate + "' where loginname='" + gname + "' and istalk in(0,1)");
					
				}
				catch (Exception Err)
                {
                        /*Response.Write("<script>alert('操作错误');history.back();</script>");
                        Response.End();*/
                }

			}
            //Showwaitdata();
    
    }

/*    public void Showwaitdata()
    {
        wheresql = "where istalk=0 and datediff('d',date(),udate)=0";

        RecordCount = (int)Socut.Data.ExecuteScalar("select count(*) from web_talkuser where istalk=0 and datediff('d',date(),logintime)=0");
        //Response.Write(RecordCount);
        //Response.End();
        waiter.Text = RecordCount.ToString();

        if (RecordCount == 0)
        {
            //Socut.Data.ExecuteNonQuery("update [web_talkuser] set talktime=date() where loginname=" + uname + " and uip=" + uip + "");
            Response.Redirect("talk/chatRoom.html");
        }


    }*/

    public string htmlstr(string chr)
    {
        if (chr == null)
            return "";
        //chr = chr.Replace("<", "&lt");
        //chr = chr.Replace(">", "&gt");
        chr = chr.Replace("\n", "<br>");
        //chr = chr.Replace("\"", "&quot;");
        //chr = chr.Replace("'", "&#39;");
        //chr = chr.Replace(" ", "&nbsp;");
        chr = chr.Replace("select", "");
        chr = chr.Replace("delete", "");
        chr = chr.Replace("update", "");
        chr = chr.Replace("drop", "");
        //chr = chr.Replace(";", "");
        //chr = chr.Replace("(", "");
        //chr = chr.Replace(")", "");
        chr = chr.Replace("and", "");
        chr = chr.Replace("or", "");
        //chr = chr.Replace("\r", "");
        return (chr);
    }

    static bool IsNumeric(string str)
    {
        if (str == null || str.Length == 0)
            return false;
        foreach (char c in str)
        {
            if (!Char.IsNumber(c))
            {
                return false;
            }
        }
        return true;
    }
}
